
##TESTS OF VARIANCE AND DIFFERENCE IN MEANS (TABLE B.1)##

import excel "C:\Power sharing VA HA\endog test data.xlsx", sheet("Sheet1") firstrow
sdtest v2x_veracc_osp, by(ps_any)
sdtest v2x_veracc_osp, by(ps_cons)
sdtest v2x_horacc_osp, by( ps_any)
sdtest v2x_horacc_osp, by( ps_cons)
sdtest v2x_feduni, by( ps_any)
sdtest v2x_feduni, by( ps_cons)
sdtest civilwar, by( ps_any)
sdtest civilwar, by( ps_cons)
gen popdens = pop/area
gen logpopdens = log(popdens)
sdtest logpopdens, by( ps_any)
sdtest logpopdens, by( ps_cons)
sdtest lmtn, by( ps_any)
sdtest lmtn, by( ps_cons)
sdtest british, by( ps_any)
sdtest british, by( ps_cons)
sdtest ethpol, by( ps_any)
sdtest ethpol, by( ps_cons)
sdtest preg90, by( ps_any)
sdtest preg90, by( ps_cons)
sdtest nrrent, by(ps_any)
sdtest nrrent, by( ps_cons)
gen loggdppc = log(gdppc)
sdtest loggdppc, by( ps_any)
sdtest loggdppc, by( ps_cons)
ttest v2x_veracc_osp, by(ps_any)
ttest v2x_veracc_osp, by(ps_cons)
ttest v2x_horacc_osp, by( ps_any)
ttest v2x_horacc_osp, by( ps_cons)
ttest v2x_feduni, by( ps_any)
ttest v2x_feduni, by( ps_cons)
ttest civilwar, by( ps_any)
ttest civilwar, by( ps_cons)
ttest logpopdens, by( ps_any)
ttest logpopdens, by( ps_cons)
ttest lmtn, by( ps_any)
ttest lmtn, by( ps_cons)
ttest british, by( ps_any)
ttest british, by( ps_cons)
ttest ethpol, by( ps_any)
ttest ethpol, by( ps_cons)
ttest preg90, by( ps_any)
ttest preg90, by( ps_cons)
ttest nrrent, by(ps_any)
ttest nrrent, by( ps_cons)
ttest loggdppc, by( ps_any)
ttest loggdppc, by( ps_cons)


clear
import excel "C:\Power sharing VA HA\PCPSVAHA.R&R.xlsx", sheet("Sheet1") firstrow 

##FIGURE 1##

preserve
collapse (mean) v2x_polyarchy polyarchy_liberia polyarchy_bur, by(year)
twoway (line v2x_polyarchy year, legend(all)) (line polyarchy_liberia year, legend(all)) (lin
> e polyarchy_bur year, legend(all)), xtitle(Year) ytitle(Electoral Democracy Index) ylabel(0 0
> .25 0.5 0.75 1) scheme(s2mono)
restore

xtset country_id year
ssc install outreg2


##RESCALING VARIABLES##

gen logpop=ln(pop)
gen logarea=ln(area)
gen loggdppc=ln(gdppc)
gen logppppc=ln(ppppc)
gen loginfmor=ln(infmort)

##UPTURNS VS DOWNTURNS - DV HORIZONTAL ACCOUNTABILITY##

gen ha_up=d.v2x_horacc_osp
replace ha_up=0 if d.v2x_horacc_osp<=0
gen ha_down=d.v2x_horacc_osp
replace ha_down=0 if d.v2x_horacc_osp>=0
gen jucon_up=d.v2x_jucon
replace jucon_up=0 if d.v2x_jucon<=0
gen jucon_down=d.v2x_jucon
replace jucon_down=0 if d.v2x_jucon>=0
gen legcon_up=d.v2xlg_legcon
replace legcon_up=0 if d.v2xlg_legcon<=0
gen legcon_down=d.v2xlg_legcon
replace legcon_down=0 if d.v2xlg_legcon>=0
gen regcorr_up=d.v2xnp_regcorr
replace regcorr_up=0 if d.v2xnp_regcorr<=0
gen regcorr_down=d.v2xnp_regcorr
replace regcorr_down=0 if d.v2xnp_regcorr>=0
gen execcorr_up=d.v2x_execorr
replace execcorr_up=0 if d.v2x_execorr<=0
gen execcorr_down=d.v2x_execorr
replace execcorr_down=0 if d.v2x_execorr>=0
gen rol_up=d.v2x_rule
replace rol_up=0 if d.v2x_rule<=0
gen rol_down=d.v2x_rule
replace rol_down=0 if d.v2x_rule>=0

##UPTURNS VS DOWNTURNS - DV VERTICAL ACCOUNTABILITY##
 
gen va_up=d.v2x_veracc_osp
replace va_up=0 if d.v2x_veracc_osp<=0
gen va_down=d.v2x_veracc_osp
replace va_down=0 if d.v2x_veracc_osp>=0
gen party_up=d.v2xps_party
replace party_up=0 if d.v2xps_party<=0
gen party_down=d.v2xps_party
replace party_down=0 if d.v2xps_party>=0
gen clean_up=d.v2xel_frefair
replace clean_up=0 if d.v2xel_frefair<=0
gen clean_down=d.v2xel_frefair
replace clean_down=0 if d.v2xel_frefair>=0
gen turnout_up=d.v2elvaptrn
replace turnout_up=0 if d.v2elvaptrn<=0
gen turnout_down=d.v2elvaptrn
replace turnout_down=0 if d.v2elvaptrn>=0
gen partic_up=d.v2x_partip
replace partic_up=0 if d.v2x_partip<=0
gen partic_down=d.v2x_partip
replace partic_down=0 if d.v2x_partip>=0
gen cs_up=d.v2x_cspart
replace cs_up=0 if d.v2x_cspart<=0
gen cs_down=d.v2x_cspart
replace cs_down=0 if d.v2x_cspart>=0
gen client_up=d.v2xnp_client
replace client_up=0 if d.v2xnp_client<=0
gen client_down=d.v2xnp_client
replace client_down=0 if d.v2xnp_client>=0
gen women_up=d.v2x_gender
replace women_up=0 if d.v2x_gender<=0
gen women_down=d.v2x_gender
replace women_down=0 if d.v2x_gender>=0
gen equal_up=d.v2xeg_eqaccess
replace equal_up=0 if d.v2xeg_eqaccess<=0
gen equal_down=d.v2xeg_eqaccess
replace equal_down=0 if d.v2xeg_eqaccess>=0

##HORIZONTAL ACCOUNTABILITY TESTS (TABLE 2)##

xtpcse ha_up l.v2x_horacc_osp pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", replace ctitle("HA Index +")
xtpcse ha_down l.v2x_horacc_osp pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("HA Index -")
xtpcse jucon_up l.v2x_jucon pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Judicial Constraints +")
xtpcse jucon_down l.v2x_jucon pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Judicial Constraints -")
xtpcse legcon_up l.v2xlg_legcon pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Legislative Constraints +")
xtpcse legcon_down l.v2xleg_legcon pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Legislative Constraints -")
xtpcse rol_up l.v2x_rule pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Rule of Law +")
xtpcse rol_down l.v2x_rule pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Rule of Law -")
xtpcse regcorr_up l.v2x_regcorr pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Regime Corruption +")
xtpcse regcorr_down l.v2x_regcorr pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Regime Corruption -")
xtpcse execcorr_up l.v2x_execorr pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Executive Corruption +")
xtpcse execcorr_down l.v2x_execorr pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg.doc", append ctitle("Executive Corruption -")


##VERTICAL ACCOUNTABILITY TESTS (TABLE 3)##

xtpcse va_up l.v2x_veracc_osp pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", replace ctitle("Vertical Accountability +")
xtpcse va_down l.v2x_veracc_osp pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Vertical Accountability -")
xtpcse party_up l.v2xps_party pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Party Inst +")
xtpcse party_down l.v2xps_party pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Party Inst -")
xtpcse partic_up l.v2x_partip pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Participatoin +")
xtpcse partic_down l.v2x_partip pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Participatoin -")
xtpcse client_up l.v2xnp_client pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Clientelism +")
xtpcse client_down l.v2xnp_client pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Clientelism -")
xtpcse women_up l.v2x_gender pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Women +")
xtpcse women_down l.v2x_gender pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Women -")
xtpcse equal_up l.v2xeg_eqaccess pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Equal Access +")
xtpcse equal_down l.v2xeg_eqaccess pps_cons pps_trans v2x_feduni logarea logpop ethpol lmtn loggdppc loginfmor gdpgrw nrrent british civilwar otherpa, p
outreg2 using "havareg3.doc", append ctitle("Equal Access -")


